/*	Usage:  request('login.php', {'password':pwd, 'username':un});
 * 
 */

function request(path, params, method) 
{
    method = method || "post";	// default post method
    
    var form = document.createElement("form");
    
    form.setAttribute("method", method);
    form.setAttribute("action", path);

     for(var key in params) {
        var hiddenField = document.createElement("input");
        hiddenField.setAttribute("type", "hidden");
        hiddenField.setAttribute("name", key);
        hiddenField.setAttribute("value", params[key]);

        form.appendChild(hiddenField);
    }

    document.body.appendChild(form); 
    form.submit();
}



function requestPage(path, id, page, order)
{
	var params = new Array();
	
	params['checkcode'] ="scvd#!342";
	params['id'] 		= id;
	params['page'] 		= page;
	params['order'] 	= order;
		
	request(path, params, 'post');
}


function showSubMenu(id) 
{
	$('#mainmenu A').removeClass('mainMenuBGover');
	$('#mainmenu_' + id).addClass('mainMenuBGover');
	
	$('#submenu UL').hide();
	$('#submenu_' + id).slideToggle(615);

}




showSubMenu(1);







function vote(url, id, voteType)
{
	var oVote = $('#' + voteType + '_' + id);
	var voteValue = oVote.text().replace(/(^\s*)(\s*$)/g, '').replace(/\r/ig, "").replace(/\n/ig, "");
	
	if(isNaN(voteValue)){
		voteValue = 0;
	}
	
	voteValue++;
	
	oVote.text(voteValue);
	
	$.get(url + "/vote.php", {Action:"get", couponId:id, type:voteType}, function (data, textStatus)
	{
//		this;
//		alert(data);
//		alert(textStatus);
		
	});
}

function addComments(url, id)
{
	var oComments 		= $('#comments_' + id);
	var oCommentsValue 	= oComments.val();
	
	$.post(url + "/comments.php", {couponId:id, comments:oCommentsValue}, function (data, textStatus)
	{
		this;
		alert(data);
//		alert(textStatus);
		
	});
}


